package com.dengqi.mymodule.activity.network.module;

import com.dengqi.mymodule.activity.network.base.BasePresenter;
import com.dengqi.mymodule.activity.network.bean.CityBean;
import com.module.retrofit.bean.ResponseBean;
import com.module.retrofit.RetrofitHelper;
import com.module.retrofit.callback.BaseObserver;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import java.util.List;


/**
 * @Author: dengqi
 * @CreateDate: 2020-10-15 19:51
 * @Description:
 */
public class CityPresenter extends BasePresenter implements CityContract.Presenter {

    private CityContract.Model model;

    public CityPresenter(RxAppCompatActivity activity){
        super(activity);
        this.model = RetrofitHelper.getApiService(CityContract.Model.class);
    }

    @Override
    public void getCityLists(CityContract.CityView view) {
        execute(model.getCityLists())
                .subscribe(new BaseObserver<ResponseBean<List<CityBean>>>(activity) {
                    @Override
                    public void onSuccess(ResponseBean<List<CityBean>> result) {
                        view.onCityLists(result.getData());

                    }

                });
    }
}
